//
// Created by Mengyu Li on 2021/4/25.
//

import CoreText
import Foundation
import UIKit

public extension String {
    // swiftlint:disable legacy_objc_type
    func size(font: UIFont, width: CGFloat) -> CGSize {
        let ocString = self as NSString
        let size = ocString.boundingRect(with: CGSize(width: width, height: .infinity), options: .usesLineFragmentOrigin, attributes: [NSAttributedString.Key.font: font], context: nil).size
        return size
    }
}
